package cn.edu.scau.cmi.yangqing.adapter;

import java.net.URL;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.ResourceBundle;

import cn.edu.scau.cmi.yangqing.factory.Creator;
import cn.edu.scau.cmi.yangqing.factory.CreatorPICC;
import cn.edu.scau.cmi.yangqing.factory.CreatorPingan;
import cn.edu.scau.cmi.yangqing.factory.Insurance;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.TextField;

public class MyController implements Initializable {

	   @FXML
	   private Button myButton;
	   
	   @FXML
	   private ChoiceBox<String> myChoiceBox;

	   @FXML
	   private ChoiceBox<String> myChoiceBox2;
	   
	   @FXML
	   private TextField myTextField2;
	   
	   
	   public void initialize(URL location, ResourceBundle resources) {
	   }

	   public void showDateTime(ActionEvent event) {
	       System.out.println("ButtonClass Clicked!");
	       Target target = null;
	       String output = "";
	       
	       System.out.println(myChoiceBox.getSelectionModel().getSelectedIndex());
	       
	       Integer checkboxIndex = myChoiceBox.getSelectionModel().getSelectedIndex();
	       Integer checkboxIndex2 = myChoiceBox2.getSelectionModel().getSelectedIndex();
	      
	       switch (checkboxIndex2) {
				case 0:
					target = new AdapterOfClass();
					break;
				case 1:
					target = new AdapterOfObject();
					break;
				default:
					break;
		 }
	       if(target.getClass().equals(AdapterOfClass.class))
	    	   output+="类适配器：";
	       switch (checkboxIndex) {
			case 0:
				output += target.operationTo5();
				break;
			case 1:
				output += target.operationTo220();
				break;
			default:
				break;
		}
	      
	       myTextField2.setText(output);
	
	   }
	   
}
